<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>The Apache Tomcat 5.5 Servlet/JSP Container - Building Tomcat</title><meta content="Remy Maucherat" name="author"><style media="print" type="text/css">
			.noPrint {display: none;}
			td#mainBody {width: 100%;}
		</style></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="0" width="100%" border="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt="
      The Apache Tomcat Servlet/JSP Container
    " align="right" src="./../images/tomcat.gif"></a></td><td><h1><font face="arial,helvetica,sanserif">The Apache Tomcat 5.5 Servlet/JSP Container</font></h1></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="./../images/asf-logo.gif"></a></td></tr></table><table cellspacing="4" width="100%" border="0"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade="noshade"></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td id="mainBody" align="left" valign="top" width="80%"><h1>The Apache Tomcat 5.5 Servlet/JSP Container</h1><h2>Building Tomcat</h2><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
<ul><li><a href="#README">README</a></li><li><a href="#Introduction">Introduction</a></li><li><a href="#Download_and_install_a_Java_Development_Kit_1.4.x_or_later">Download and install a Java Development Kit 1.4.x or later</a></li><li><a href="#Install_Apache_Ant_1.6.2_or_later">Install Apache Ant 1.6.2 or later</a></li><li><a href="#Building_Tomcat">Building Tomcat</a></li><li><a href="#Updating_and_rebuilding_Tomcat_sources">Updating and rebuilding Tomcat sources</a></li><li><a href="#Building_with_Eclipse">Building with Eclipse</a></li><li><a href="#Building_with_other_IDEs">Building with other IDEs</a></li></ul>
</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="README"><strong>README</strong></a></font></td></tr><tr><td><blockquote>
<p>
This document duplicates some of the information from the BUILDING.txt file
included in every Tomcat distribution.  You may want to consult both.
</p>
</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>

<p>
Building Tomcat from SVN is very easy, and is the first step to contributing to
Tomcat. The following is a step by step TODO list.
</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Download and install a Java Development Kit 1.4.x or later"><!--()--></a><a name="Download_and_install_a_Java_Development_Kit_1.4.x_or_later"><strong>Download and install a Java Development Kit 1.4.x or later</strong></a></font></td></tr><tr><td><blockquote>

<p>
The default distribution of Tomcat 5.5.x requires a 5.0 or later JDK. Tomcat
can be built using a 1.4.x JDK but you will need to copy the contents of the
compat directory (created by the build process) to your build directory before
Tomcat will start.
</p>

<p>
The Sun JDK can be downloaded <a href="http://java.sun.com/j2se/">here</a>.
</p>

<p>
<b>IMPORTANT</b>: Set an environment variable JAVA_HOME to the pathname of the 
directory into which you installed the JDK release.
</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Install Apache Ant 1.6.2 or later"><!--()--></a><a name="Install_Apache_Ant_1.6.2_or_later"><strong>Install Apache Ant 1.6.2 or later</strong></a></font></td></tr><tr><td><blockquote>

<p>
Download a binary distribution of Ant 1.6.2 or later from 
<a href="http://ant.apache.org/bindownload.cgi">here</a>.
</p>

<p>
Unpack the binary distribution into a convenient location so that the
Ant release resides in its own directory (conventionally named
"apache-ant-1.6.x").  For the purposes of the remainder of this document,
the symbolic name "${ant.home}" is used to refer to the full pathname of
 the release directory.
</p>

<p>
Create an ANT_HOME environment variable to point the directory ${ant.home}, 
and modify the PATH environment variable to include directory
"${ant.home}/bin" in its list.  This makes the "ant" command line script
available, which will be used to actually perform the build.
</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Building Tomcat"><!--()--></a><a name="Building_Tomcat"><strong>Building Tomcat</strong></a></font></td></tr><tr><td><blockquote>

<p>
Download the main build.xml script from <a href="build.xml">here</a>.
</p>

<p>
Create a new directory, and copy the newly download build.xml to it. This
  directory will be referred to as the ${tomcat.source} directory in the rest
  of this document.
</p>

<p>
Go to that directory, and do:
<code><br>
    cd ${tomcat.source}<br>
    ant<br>
</code>
</p>

<p>
NOTE: Users accessing the Internet through a proxy must use a properties
  file to indicate to Ant the proxy configuration. Read below.
</p>

<p>
WARNING: Running this command will checkout the Tomcat 5 sources from SVN, as
  well as download binaries to the <code>/usr/share/java</code> directory. 
  Make sure this is appropriate to do so on your computer. On Windows, 
  this usually corresponds to the <code>C:\usr\share\java</code> directory, 
  unless Cygwin is used. Read below to customize the directory used 
  to download the binaries.
</p>

<p>
The build can be controlled by creating a ${tomcat.source}/build.properties
  file, and adding the following content to it:
<code><br>
    # ----- Proxy setup -----<br>
    # Uncomment if using a proxy server.<br>
    #proxy.host=proxy.domain<br>
    #proxy.port=8080<br>
    #proxy.use=on<br>
<br>
    # ----- Default Base Path for Dependent Packages -----<br>
    # Replace this path with the directory path where<br>
    # dependencies binaries should be downloaded.<br>
    base.path=/usr/share/java<br>
</code>
</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Updating and rebuilding Tomcat sources"><!--()--></a><a name="Updating_and_rebuilding_Tomcat_sources"><strong>Updating and rebuilding Tomcat sources</strong></a></font></td></tr><tr><td><blockquote>

<p>
It is recommended to regularly update the downloaded Tomcat 5 sources. 
To do this, execute the following commands:

<code><br>
    cd ${tomcat.source}<br>
    ant checkout<br>
</code>
</p>

<p>
For a quick rebuild of only modified code you can use:
<code><br>
    cd ${tomcat.source}<br>
    ant build<br>
</code>

</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Building with Eclipse"><!--()--></a><a name="Building_with_Eclipse"><strong>Building with Eclipse</strong></a></font></td></tr><tr><td><blockquote>

<p>
<b>Important:</b>
This is not a supported means of building Tomcat; this information is
provided without warranty :-).
The only supported means of building Tomcat is with the "ant build"
described above.
However, some developers like to work on Java code with a Java IDE,
and the following steps have been used by some developers.
</p>

<p>
Note that you <b>must</b> complete all the above steps to fetch
the repositories and build some JAR files the first time.
After you have completed the above steps, you can set up a
series of Eclipse 4 projects.
<b>Note</b> that this will not let you build everything under Eclipse;
the build process requires use of Ant for the many stages that aren't
simple Java compilations.
However, it will allow you to view and edit the Java code,
get warnings, reformat code, perform refactorings, run Tomcat
under the IDE, and so on.
</p>

<p>You will want to set up your Eclipse project for building Tomcat such that
${tomcatSource} is the Workspace folder.
</p>

<p>
Use Windows-&gt;Preferences and then Java-&gt;Build Path-&gt;Classpath
Variables to add two new Classpath variables:
</p>

<p>
<table border="1">
 <tr><td>TOMCAT_LIBS_BASE</td><td>the base path where the binary dependencies have been downloaded</td></tr>
 <tr><td>ANT_HOME</td><td>the base path of Ant 1.6.2 or later</td></tr>
</table>
</p>

<p>
Use File-&gt;New Project to create a new Java project 
for each of the binaries repository (e.g., /usr/share/java), 
container, connectors, jasper, servletapi. 
If you didn't already set up the Eclipse project such that ${tomcat.source} 
is the Workspace folder, do so now: 
tell Eclipse the external location using "Import/Export...",
General-&gt;Existing Project into Workspace.
</p>

<p>
Eclipse .project and .classpath files are provided in each of these
directories so Eclipse should find all source trees and jars, and
hopefully compile without problems. <b>Note</b> that these
files assume you are using Eclipse with a 5.0 or later JDK; also, the
connectors module must be built with a compiler compliance level of 5.0.
</p>

<p>
To run Tomcat without a special IDE plug-in, you can simply use Run-&gt;Run...
enter "org.apache.catalina.startup.Catalina" as the main class,
"start" as program arguments, and
"-Dcatalina.home=..." (with the name of your build directory) 
as VM arguments.
</p>

<p>
Note also that due to the way the Tomcat source is assembled
from several SVN projects, you may not be able to use the Eclipse
SVN client to update (nor to commit, if you are a committer).
Use the external SVN client of your choice, then use the
Eclipse PackageExplorer or Navigator "Refresh" context menu item
to tell Eclipse that you've updated the files.
</p>

</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Building with other IDEs"><!--()--></a><a name="Building_with_other_IDEs"><strong>Building with other IDEs</strong></a></font></td></tr><tr><td><blockquote>
<p>
The same caveats apply as for Eclipse, above.
</p>

<p>
The same general idea should work in most IDEs; it has been reported
to work in Idea, for example.
</p>

</blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade="noshade"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em>
        Copyright &copy; 1999-2011, Apache Software Foundation
        </em></font></div></td></tr></table></body></html>